home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-10-26 | 2.2 KB | 68 lines | [TEXT/ScoM] |
- Sorry, this is not possible.
-
- (defun symbol-adjust (n &rest l)
- (def-neuron chsyocd
- (all-in 1 '(a a) 0 26 -1)
- (transpose-one-symbol (in 1 0) n)
- (otherwise (in 1 0)))
- (apply 'run-neuron 'chsyoch l))
-
- Why? The neuron definition cannot contain variables.
- Why not? When the activated neuron is conjugating its rules
- and when a rule is fired (transpose-one-symbol (in 1 0) n)
- is evaluated with (eval ...) which cannot know that n is
- bound to a value. How to bound n to a value? There is a
- solution, which is a dirty one:
-
- (defvar n nil) ; make a global variable
-
- (defun testfun (variable &rest l)
- (def-neuron test1
- (in 1 'a)
- (transpose-one-symbol (in 1 0) n) ; use here the global variable
- (otherwise '=)
- )
- (setq n variable) ; set n to contain the variable used in the function
- (apply 'run-neuron 'test1 l)) ; now this should execute properly
-
- ; test it
-
- (testfun 1 '(a b a a))
- --> (b = b b) ; only symbol a is transposed
-
- This is a dirty solution since it uses a global variable as
- a passway, and if you are using recursive neuron calls the
- values get mixed up. But as neuron recursion is not allowed
- you may use this, but remember not to use same global parameters
- in more that one neuron, or use and the results would be
- quite interesting, far from illogical, though difficult to
- trace back. (I heard once a very natural sounding piece of
- music. Then the creator said it was a software mistake he
- could not replicate when he got the algorithm working properly
- ...)
-
- Better solution would be to define neuron-apply
- function, which pushes the variable into the neural environmental
- bindings, and define neuron-eval which is used to evaluate
- all rules so that it first checks if environmental variables
- exist in the fire-rules, and if so, replace the variables with
- the values and evaluate the newly created function with standard
- eval.
-
- Your function:
-
- (defvar n nil)
-
- (defun symbol-adjust (variable &rest l)
- (def-neuron chsyocd
- (all-in 1 '(a a) 0 26 -1)
- (transpose-one-symbol (in 1 0) n)
- (otherwise (in 1 0)))
- (setq n variable)
- (apply 'run-neuron 'chsyocd l))
-
- (symbol-adjust -1 '(a a b b c d))
- --> (a -b b a c d)
-
- That finds a same-sequence-2 and transposes the second one -1.
-